package com.gnrsoft.rpc.client;

import java.lang.reflect.Proxy;

import com.gnrsoft.rpc.registry.ServiceDiscovery;

public class RpcProxy {

	private ServiceDiscovery serviceDiscovery;

	public RpcProxy() {
	}

	public RpcProxy(ServiceDiscovery serviceDiscovery) {
		this.serviceDiscovery = serviceDiscovery;
	}

	@SuppressWarnings("unchecked")
	public <T> T newProxyInstance(Class<T> classz) {
		return (T) Proxy.newProxyInstance(classz.getClassLoader(), new Class[] { classz },
				new RpcInvocationHandler(serviceDiscovery));

	}

}
